﻿///Code based on
/// http://chessbin.com/page/Chess-Game-Starer-Kit.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Models
{
    public class MovesInfo
    {
        public int DestColumn { get; set; }

        public int DestRow { get; set; }
        public int SourceColumn { get; set; }

        public int SourceRow { get; set; }

        public MovesInfo()
        {
            
        }
        public MovesInfo(int destCol, int destRow, int sourceCol, int sourceRow)
        {
            this.DestColumn = destCol;
            this.DestRow = destRow;
            this.SourceColumn = sourceCol;
            this.SourceRow = sourceRow;
        }

        public string WriteDestPos()
        {
            string row = "";
            string desCol = "";
            switch (DestColumn)
            {
                case 0:
                    desCol = "a";
                    break;
                case 1:
                   desCol = "b";
                    break;
                case 2:
                    desCol = "c";
                    break;
                case 3:
                    desCol = "d";
                    break;
                case 4:
                    desCol = "e";
                    break;
                case 5:
                    desCol = "f";
                    break;
                case 6:
                    desCol = "g";
                    break;
                case 7:
                    desCol = "h";
                    break;
            }

            switch (DestRow)
            {
                case 0:
                    row = "8";
                    break;
                case 1:
                    row = "7";
                    break;
                case 2:
                    row = "6";
                    break;
                case 3:
                    row = "5";
                    break;
                case 4:
                    row = "4";
                    break;
                case 5:
                    row = "3";
                    break;
                case 6:
                    row = "2";
                    break;
                case 7:
                    row = "1";
                    break;
            }

            return desCol + row;
        }

        public string WriteSourcePos()
        {
            string row = "";
            string srcCol = "";
            switch (SourceColumn)
            {
                case 0:
                    srcCol = "a";
                    break;
                case 1:
                    srcCol = "b";
                    break;
                case 2:
                    srcCol = "c";
                    break;
                case 3:
                    srcCol = "d";
                    break;
                case 4:
                    srcCol = "e";
                    break;
                case 5:
                    srcCol = "f";
                    break;
                case 6:
                    srcCol = "g";
                    break;
                case 7:
                    srcCol = "h";
                    break;
            }

            switch (SourceRow)
            {
                case 0:
                    row = "8";
                    break;
                case 1:
                    row = "7";
                    break;
                case 2:
                    row = "6";
                    break;
                case 3:
                    row = "5";
                    break;
                case 4:
                    row = "4";
                    break;
                case 5:
                    row = "3";
                    break;
                case 6:
                    row = "2";
                    break;
                case 7:
                    row = "1";
                    break;
            }

            return srcCol + row;
        }

        public string WriteFullMove()
        {
            return WriteSourcePos() + WriteDestPos();
        }
    }
}
